package cn.fss.elasticsearch.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ElasticsearchConfig {
	@Value("${es.elasticsearch.url}")
	private String esHost;

	@Value("${es.elasticsearch.port}")
	private int esPort;

	@Bean
	public RestHighLevelClient restHighLevelClient() {
		// 设置连接的用户名密码
		return new RestHighLevelClient(RestClient.builder(new HttpHost(esHost, esPort, "http")));
	}
}
